{% extends 'layout.html' %}
<!--
继承+重写
-->
{%block main%}
<div class="blog-container">
    <div class="">添加内容页面</div>
    <div>当前用户：{{userinfo.username}}（{{userinfo._id}}）</div>
    <h3>添加内容</h3>
    <form method="post">
        <div class="box">
            <label for="category">分类</label>
            <select name="category" id="category">
                {%for item in typelist%}
                <option value="{{item._id.toString()}}">{{item.name}}</option>
                {%endfor%}
            </select>
        </div>
        <div class="box">
            <label for="title">标题</label>
            <div>
                <input type="text" id="title" name="title" placeholder="请输入标题">
            </div>
        </div>
        <div class="box">
            <label for="distribution">简介</label>
            <div>
                <input type="text" id="distribution" name="distribution" placeholder="请输入简介">
            </div>
        </div>
        <div class="box">
            <label for="content">内容</label>
            <div>
                <textarea id="content" name="content" cols="80" rows="10" placeholder="请输入内容"></textarea>
            </div>
        </div>
        <div class="blog-submit-grp">
            <button type="submit" name="submit" id="tj" class="btn-x">提交</button>
        </div>


    </form>

</div>
<script>
    // bodyparser插件解析模式有问题，暂时只能用axios去提交请求
    // $(document).on('click','#tj',function () {
    //     const name = document.getElementById('name').value;
    //     const dd = {
    //         name: name
    //     };
    //     axios({
    //         method: 'post',
    //         url: '/admin/content/add',
    //         data: dd
    //     }).then(function (response) {
    //         alert(response.data.name);
    //         window.location.href='http://localhost:8080/'+response.data.url;
    //
    //     });
    // });
</script>
{%endblock%}

